/*******************************************************************************
 * Copyright 2010 Prometheus Consulting
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package nz.co.senanque.validationengine;

import java.util.ArrayList;
import java.util.List;

import nz.co.senanque.validationengine.metadata.ClassMetadata;

/**
 * Wraps the proxy object so it can be accessed for public use
 * 
 * @author Roger Parkinson
 * @version $Revision: 1.7 $
 */
public class ObjectMetadata
{

    private transient ProxyObject m_proxyObject;

    private transient ClassMetadata m_classMetadata;

    public ObjectMetadata()
    {
    }
    protected void setClassMetadata(final ProxyObject proxyObject, final ClassMetadata classMetadata)
    {
        m_proxyObject = proxyObject;
        m_classMetadata = classMetadata;
    }

    public FieldMetadata getFieldMetadata(final String name)
    {
        return new FieldMetadata(m_proxyObject.getProxyField(name),
                m_classMetadata.getField(name));
    }
    public ProxyField getProxyField(final String name)
    {
        return m_proxyObject.getProxyField(name);
    }
    public List<ProxyField> getProxyFields(final String ref, final String field)
    {
        List<ProxyField> ret = new ArrayList<ProxyField>();
        ProxyField refField = m_proxyObject.getProxyField(ref);
        Object o = refField.fetchValue();
        return ret;
    }
}
